package com.mcb_wxc.service;

import com.mcb_wxc.util.CodeUtil;
import com.mcb_wxc.util.ReturnJsonResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 小生
 * 2019/1/11 17:10.
 * 配合h+写的标签显示管理
 */
@Api(tags = "TEMPLATE", description = "模板")
@RestController
@RequestMapping(value="/templateService")
public class TemplateService {
    @Autowired
    HttpServletRequest request;

    /**
     * @api {GET} /templateService/getTemplate 获取模板
     * @apiName getTemplate
     * @apiGroup template
     * @apiDescription  获取模板
     * @apiVersion 1.0.0
     * @apiParam {String} template  测试参数
     * @apiSuccess {JsonObject} result 返回对象
     * @apiSuccess {Integer} result.resultCode 调用是否成功, 1 是 0 否.
     * @apiSuccess {String} result.content 返回的描述性话语, 当resultCode为0时输出异常信息
     */
    @ApiOperation(value="getTemplate", notes="主页模板查询" , httpMethod = "GET", response = TemplateService.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentId",value = "用户id",required = false,dataType = "Integer",paramType="query"),
    })
    @RequestMapping(value = "/getTemplate" , method = RequestMethod.GET)
    public String getTemplate(Integer agentId) {
        ReturnJsonResultUtil result = new ReturnJsonResultUtil();
        List<String> list = new ArrayList<>();
        try{
            list.add("店面管理");
            list.add("城市管理");
            list.add("账号管理");
            result.setMainData(list);
        }catch (Exception e) {
            result.printLog(request,e);
            result.setResultCode(CodeUtil.FAIL);
            result.setContent(CodeUtil.SERVER_ERROR);
        }
        return result.toString();
    }

}
